import request  from "./AxiosRequest.js";
var vm = new Vue({
    el : '#dpLTE',
    data : {
        privkey : 'MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBALwlTWcENnk+BE0DGSxML8yVoFffu+NMfzimnOa4Skft7objdBd3tmh/xqkgnh5+TpSLDb84l+TIwYOwAlO//Nae4qbpR7IFjG2A/kkUa1MwpMFW4bMfxTNhZ0/PJsg4KaPnlCS7edgRnKujfx0aFIUtI9pTd6hjW1uWblkUn7x7AgMBAAECgYEAsoOaK1Jd9S+YmRGFgvhOqgiV+Ip6FTJxy2iamnblU9Y3aZjKf7HASuphrfsay8f/+wTs6DBkPlkU80O/EYOp+r46UIKq5KChW2ErUVaMyxO4f8l0PW2RFHFYWq54SbRa73DepPeC3o9LRinEaJ7/rk13EHiS6RAPkFr/ZyTOYdECQQD0BNI4Wg4gJqZHC1QCHOQUaF2cDWh5cadWT9FOXKdgRUrP+2W67BJP/RjNPT++/cyP3pdNc8vMCkF8IGgJ7Pk/AkEAxWIwCK3prAxupNrlUhPNT+nfG05Bs0SYIQHSiwUykXkcUZAcAveNk2g8XlhAQ4fEZG9BQ0+MlA246FV90NlRxQJAJEm7QWoTA7D7tUD4A0BsoqRKl3Re/wBp1CoWhEK/GU/0qi1GmZ+VsZN/5rWfDzYK/7Ioafo4amV0C5N+JUu6XQJANbDuxf2guYcsNbXBeWEfkSRZ5xCTeJMpGplnTx+b0Mxz8o/Tvs7d+QH6oeM5n+T3fCZzRz8FS2SsLq7KqZvjzQJADLfcfxaYd3V7e0/Op08ifDyCjpLa3rviNFss/msOR3Mzfg7J05wD3oVHut+g+RVF7+Gnia07pV5YnFVd0WA1UA==',
        pubkey : 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC8JU1nBDZ5PgRNAxksTC/MlaBX37vjTH84ppzmuEpH7e6G43QXd7Zof8apIJ4efk6Uiw2/OJfkyMGDsAJTv/zWnuKm6UeyBYxtgP5JFGtTMKTBVuGzH8UzYWdPzybIOCmj55Qku3nYEZyro38dGhSFLSPaU3eoY1tblm5ZFJ+8ewIDAQAB',
        toBeEncrypted : '123456789',
        encrypted : '',
        decrypted : ''
    },
    methods : {
        test : function() {
            var encrypt = new JSEncrypt();
            encrypt.setPublicKey(this.pubkey);
            this.encrypted = encrypt.encrypt(this.toBeEncrypted);
            console.log(this.encrypted)

            var decrypt = new JSEncrypt();
            decrypt.setPrivateKey(this.privkey);
            this.decrypted = decrypt.decrypt(this.encrypted);
            console.log(this.decrypted)
        },
        encryptedTest : function() {
            let data={
                mobile:"13370752411",
                nickName:"13370752411",
                avatar:"13370752411"
            };
            request.post('/api/encryption',data,{noEncrypt:true}).then(res=>{
                console.log(JSON.stringify(res));
                layer.msg('成功：'+JSON.stringify(res));
            }).catch(res => {
                console.log(JSON.stringify(res));
                layer.msg('失败！');
            });
        },
        decryptedTest : function() {
            let data={
                mobile:"13370752412",
                nickName:"13370752412",
                avatar:"13370752412"
            };
            request.post('/api/decryption',data,{noEncrypt:true}).then(res=>{
                console.log(JSON.stringify(res));
                layer.msg('成功：'+JSON.stringify(res));
            }).catch(res => {
                console.log(JSON.stringify(res));
                layer.msg('失败！');
            });
        }
    }
});